package il.ac.bgu.cs.heuristics.graph.pddl.parser;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Test;

public class ParserTests extends TestCase{ // NOPMD too many methods

	@Test
	public void testExpressionParse01() {
		try {
			ExpressionParser.parsePredicate("");
			Assert.fail("parse should not succeed");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue(true);
		}
	}

	@Test
	public void testExpressionParse02() {
		try {
			ExpressionParser.parsePredicate("(not)");
			Assert.fail("parse should not succeed");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue(true);
		}
	}

	@Test
	public void testExpressionParse03() {
		try {
			ExpressionParser.parsePredicate("(not and)");
			Assert.fail("parse should not succeed");
		} catch (IllegalArgumentException e) {
			Assert.assertTrue(true);
		}
	}

	@Test
	public void testExpressionParse04() {
		try {
			ExpressionParser.parsePredicate("(has-bananas)");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse05() {
		try {
			ExpressionParser.parsePredicate("(not (has-bananas))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse06() {
		try {
			ExpressionParser.parsePredicate("(not (has-bananas ?x - person))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse07() {
		try {
			ExpressionParser
			        .parsePredicate("(not (has-bananas ?x - (either person turtle)))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse08() {
		try {
			ExpressionParser
			        .parsePredicate("(not (has-bananas ?x - (either person turtle) ?y - dog))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse09() {
		try {
			ExpressionParser
			        .parsePredicate("(not (has-bananas ?x - (either person turtle) ?y - (either dog cat)))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse10() {
		try {
			ExpressionParser
			        .parsePredicate("(and (has-bananas ?x - (either person turtle) ?y - (either dog cat)))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse11() {
		try {
			ExpressionParser
			        .parsePredicate("(or (has-bananas ?x - (either person turtle) ?y - (either dog cat)))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse12() {
		try {
			ExpressionParser
			        .parsePredicate("(has-bananas ?x - (either person turtle) ?y - (either dog cat))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse13() {
		try {
			ExpressionParser
			        .parseLogicalExpression("(not (has-bananas ?x - (either person turtle) ?y - (either dog cat)))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse14() {
		try {
			ExpressionParser
			        .parseLogicalExpression("(not (has-bananas ?x - (either person turtle) ?y - (either dog cat)) (at ?x - (either person dog) ?y - room))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse15() {
		try {
			ExpressionParser
			        .parseLogicalExpression("(and (has-bananas ?x - (either person turtle) ?y - (either dog cat)) (not (at ?x - (either person dog) ?y - room)))");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse16() {
		try {
			ExpressionParser.parseTypedParameter("bobo - object");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

	@Test
	public void testExpressionParse17() {
		try {
			ExpressionParser
			        .parseTypedParameter("bobo - (either person animal)");
		} catch (IllegalArgumentException e) {
			Assert.fail();
		}
	}

}
